// 计数器类

#include <iostream>
using namespace std;

class Counter {
private:
    int count = 0;

public:
    Counter() = default;
    void operator++() { ++count; }
    int GetCount() { return count; }
    void SetCount(int count) { this->count = count; }
    void PrintCount() { cout << "count = " << count << "\n"; }
};

class NewCounter : public Counter {
public:
    void operator--() {
        int c = GetCount();
        --c;
        SetCount(c);
    }
};

int main() {
    NewCounter c;
    cout << "使用NewCounter类的例子\n";
    cout << "Counter是多少:\n";
    c.PrintCount();

    cout << "\nCounter增加两次\n";
    ++c;
    ++c;
    c.PrintCount();

    cout << "\nNewCounter减1\n";
    --c;
    c.PrintCount();

    cout << "\n结束\n";
}